/**
 * 检查是否函数
 * @param fn {function}
 * @returns {boolean}
 */
export const isFun = (fn: any) => typeof fn === 'function';
/**
 * 执行一个函数
 * @param fn {function} 执行函数
 * @param e {array} 参数列表
 */
export const implementFun = (fn, ...e) => {
  if(isFun(fn)) {
    fn(...e);
  ;}
};
export const isTureVal = (val: any) => {
  if (val === false) {
    return false;
  };
  if (val === undefined) {
    return false;
  }
  if (val === '') {
    return false;
  }
  if (val === null) {
    return false
  }
  if (val === 0) {
    return false;
  };
  if (val !== val) {
    return false;
  };
  return true;
}
export const isArray = (obj: any) => {
  return Object.prototype.toString.call(obj) === '[object Array]';
  }
export const isObject = (obj: any) => {
  return Object.prototype.toString.call(obj) === '[object Object]';
}
/**
 * 深复制数据，不能复制函数
 * @param json 需要拷贝的json
 * @returns 
 */
export const copyJson = (json) => JSON.parse(JSON.stringify(json));
export const stateMinute = (value) => {
  const str: number = value / 1000
  //获取小时值
  let timeH: string = "";
  let H = Math.floor(str / 3600);
  if (H >= 0 && H < 1) {
      timeH += "00:";
  } else if (H >= 1 && H < 10) {
      timeH += "0" + H + ":";
  } else {
      timeH += H + ":";
  }
  //获取分值
  let timeM = "";
  let M = Math.floor(str / 60);
  if (M === 0) {
      timeM += "00:";
  } else if (M > 0 && M < 10) {
      timeM += "0" + M + ":";
  } else {
      timeM += M + ":";
  }
  var S = Math.floor(str % 60);
  var timeS = "";
  if (S === 0) {
      timeS += "00";
  } else if (S > 0 && S < 10) {
      timeS += "0" + S;
  } else {
      timeS += S;
  }
  return timeH + timeM + timeS;
}
